/*
*		为防止大数据传送费时，进行打包压缩在入buffer发送
*/


#pragma once

#include "CxType.h"

namespace  ImitateTansfer

{
	struct CxPackage 
	{
		virtual	~CxPackage(){}
	
		virtual	char		*GetData()=0;
		virtual size_t		GetDataSize()const=0;

		static CxPackage *Package(char *src,size_t	size,int _row,int _col,int type,int	copymode=0);
	};


	class CxPackageData :public		CxPackage
	{
	public:

		CxPackageData(char *data,size_t size,int _row,int _col,int type,int copymode=0);

		~CxPackageData();

	public:

		char		*GetData(){CX_ASSERT(m_pdata);return m_pdata;}

		size_t		GetDataSize()const{CX_ASSERT(m_size);return m_size;}

		bool		IsPackage()const{return m_isPackage;}
		bool		IsCompress()const{return m_isCompress;}

	protected:

		bool		Compress();
		bool		PackageData(int _row,int  _col,int  type);

	private:
		bool				m_isCompress;
		bool				m_isPackage;
		unsigned long		m_size;
		char				*m_pdata;
	};


}

